package id.co.shuba.spamobile.task;

public class MockProgressTask extends BaseProgressTask {
	private String _title;
	
	public MockProgressTask() {
		
	}
	
	public MockProgressTask(String title) {
		_title = title;
	}
	
	public String getTitle() {
		return _title;
	}

	public void setTitle(String title) {
		_title = title;
	}

	@Override
	protected AsyncTaskResult<Void> doInBackground(Object... params) {
		try {
			publishStatus("Connecting web service...");
			Thread.sleep(500);
			publishProgress(10);
			publishStatus("Downloading...");
			Thread.sleep(1000);
			publishProgress(30);
			Thread.sleep(500);
			publishStatus("Parsing data...");
			publishProgress(50);
			publishStatus("Uploading...");
			for (int i = 51; i < 100; i++) {
				Thread.sleep(50);
				publishProgress(i);
			}
			publishStatus("Complete");
			publishProgress(100);
			
			return new AsyncTaskResult<Void>((Void)null);
		} catch (Exception e) {
			return new AsyncTaskResult<Void>(e);
		}		
	}
}
